@extends('admin.layout.main')
@section('content')
    <div class="main-content-inner">
        <div class="breadcrumbs ace-save-state" id="breadcrumbs">
            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="/admin/index">首页</a>
                </li>

                <li>
                    <a href="/admin/tpl_index">消息模板管理</a>
                </li>
                <li class="active">
                    <a href="/admin/tpl_create" >添加系统消息</a>
                </li>
            </ul><!-- /.breadcrumb -->

        </div>

        <div class="page-content">

            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->
                    <form class="form-horizontal" role="form" name="linkform" method="post"  action="/admin/tpl_update/{{$list->id}}">
                        {{csrf_field()}}
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-1">模板id </label>

                            <div class="col-sm-9">
                                <label  style="height: 2rem;line-height: 3rem;" class="col-xs-10 col-sm-5">{{$list->id}}</label>
                                {{--<input type="text"  disabled id="form-field-1"--}}
                                       {{--class="col-xs-10 col-sm-5" value="{{->id}}"/>--}}
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-1">标题 </label>

                            <div class="col-sm-9">
                                <input type="text" name="title" id="form-field-1" placeholder="填写消息标题"
                                       class="col-xs-10 col-sm-5" value="{{$list->title}}"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-select-1"> 类型 </label>

                            <div class="col-sm-9">
                                <select class="col-xs-10 col-sm-5" id="form-field-select-1" name="name">
                                    <option value="1">系统消息</option>
                                </select>

                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-select-1"> 图标 </label>

                            <div class="col-sm-9">
                                <div class="layui-upload">
                                    <button type="button" class="layui-btn" id="test1">上传图片</button>
                                    <div class="layui-upload-list">
                                        <input name="icon" value="{{$list->icon}}"  type="hidden">
                                        <img class="layui-upload-img"  src="{{$list->icon_url}}" style="max-width: 200px;" id="demo1">
                                        <p id="demoText"></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 系统消息内容 </label>
                            <div class="col-sm-9">
                                <textarea id="form-field-2" name="message" class="col-xs-10 col-sm-5 autosize-transition"
                                          style="overflow: hidden; overflow-wrap: break-word; resize: horizontal; height: 112px;">{{$list->message}}</textarea>
                            </div>
                        </div>
                        <div class="space-4"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 推送消息内容 </label>
                            <div class="col-sm-9">
                                <textarea id="form-field-2" name="push_message" class="col-xs-10 col-sm-5 autosize-transition"
                                          style="overflow: hidden; overflow-wrap: break-word; resize: horizontal; height: 112px;">{{$list->push_message}}</textarea>
                            </div>
                        </div>
                        <div class="space-4"></div>
                        <div class="form-grouop" >

                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2">是否通知</label>
                            <div class="col-sm-9">
                                <div class="radio col-xs-10 col-sm-5">
                                    <label>
                                        <input name="system" value="1" class="ace"  @if ($list->system == 1)checked @endif type="radio">
                                        <span class="lbl"> 是</span>
                                    </label>
                                    <label>
                                        <input name="system" value="0" class="ace" @if ($list->system == 0)checked @endif type="radio">
                                        <span class="lbl"> 否</span>
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="space-4"></div>

                        <div class="form-grouop" >

                            <label class="col-sm-3 control-label no-padding-right" for="form-field-2">是否推送</label>
                            <div class="col-sm-9">
                                <div class="radio col-xs-10 col-sm-5">
                                    <label>
                                        <input name="push" value="1" class="ace" @if ($list->push == 1)checked @endif type="radio">
                                        <span class="lbl"> 是</span>
                                    </label>
                                    <label>
                                        <input name="push" value="0"  class="ace" @if ($list->push == 0)checked @endif type="radio">
                                        <span class="lbl"> 否</span>
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="space-4"></div>

                        <div class="clearfix form-actions" style="margin-top: 80px">
                            <div class="col-md-offset-3 col-md-9">
                                <button id="submitBtn" class="btn btn-info" type="submit">
                                    <i class="ace-icon fa fa-check bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="ace-icon fa fa-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </div>
                    </form>
                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div>

    <script type="text/javascript">
        if('ontouchstart' in document.documentElement) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
    </script>

    <!-- page specific plugin scripts -->

    <!--[if lte IE 8]>
    <script src="assets/js/excanvas.min.js"></script>
    <![endif]-->
    <script src="{{ asset('/admin/js/bootstrap-editable.min.js') }}"></script>
    <script src="{{ asset('/admin/js/ace-editable.min.js') }}"></script>
    <script src="{{ asset('/admin/js/jquery-ui.custom.min.js') }}"></script>
    <script src="{{ asset('/admin/js/jquery.ui.touch-punch.min.js') }}"></script>
    <script src="{{ asset('/admin/js/jquery.gritter.min.js') }}"></script>
    <script src="{{ asset('/admin/js/bootbox.js') }}"></script>
    <script src="{{ asset('/admin/js/jquery.easypiechart.min.js') }}"></script>
    <script src="{{ asset('/admin/js/jquery.hotkeys.index.min.js') }}"></script>
    <script src="{{ asset('/admin/js/bootstrap-wysiwyg.min.js') }}"></script>
    <script src="{{ asset('/admin/js/select2.min.js') }}"></script>
    <script src="{{ asset('/admin/js/spinbox.min.js') }}"></script>
    <script src="{{ asset('/admin/js/jquery.maskedinput.min.js') }}"></script>

    <!-- ace scripts -->
    <script src="{{asset('admin/js/ace-elements.min.js')}}"></script>
    <script src="{{asset('admin/js/ace.min.js')}}"></script>

    <script>
        $(function () {
            var lay_upload = layui.upload;

            //普通图片上传
            var uploadInst = lay_upload.render({
                elem: '#test1',
                field:'image[]',
                url: '/admin/upload_img',
                accept: 'images',
                exts: 'jpg|jpeg|png|gif',
                data:{ _token:'{{csrf_token()}}'},
                size:1024*2
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#demo1').attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    if(res.status == 1){
                        //上传成功
                        $('#demoText').html('');

                        $('input[name=icon]').val(res.data[0]);
                        return layer.msg('上传成功');

                    }else{
                        return layer.msg('上传失败');

                    }

                }
                , error: function () {
                    //演示失败状态，并实现重传
                    var demoText = $('#demoText');
                    demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                    demoText.find('.demo-reload').on('click', function () {
                        uploadInst.upload();
                    });
                }
            });
        })
    </script>
@endsection